/* 
 * File:   plyFileReader.h
 * Author: walther
 *
 * Created on October 31, 2012, 7:51 PM
 */

#ifndef PLYFILEREADER_H
#define	PLYFILEREADER_H

#include "Scene.h"
#include "Triangle.h"
#include <rply.h>


class plyFileReader {
public:
    /**
     * Constructor
     */
    plyFileReader();
    
    /**
     * Destructor
     */
    virtual ~plyFileReader();
    
    /**
     * Reads the file and populates the given Scene object
     * @param filename Path to the file
     * @param scene Scene object that will be populated
     */
    void loadScene( std::string fileName, Scene* scene );
    
    /**
     * Returns the minimum values of x, y and z for positioning
     * @return Vector with the minimum values of he model
     */
    Vector4D getMin();
    
    std::vector<double>& getVertices();
    
    std::vector<int>& getFaces();
    
private:
    
    static int vertex_cb( p_ply_argument argument );
    static int face_cb( p_ply_argument argument );
    
    /** Pointer scene */
    Scene* _scene;
    
    /** Number of vertices */
    long _nVertices;
    
    /** Number of faces */
    long _nFaces;
    
    /** array of vertices */
    std::vector<double> _vertices;
    
    /** array of faces */
    std::vector<int> _faces;    
    
    /** minimum values of the model */
    Vector4D _min;
};

#endif	/* PLYFILEREADER_H */

